package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class CustomerTraceHistory {
    public static final int TRACERESULT_COMMON = 3 ;// 评价良好
    public static final int TRACERESULT_NORMAL = 2 ;// 评价中等
    public static final int TRACERESULT_FAIL = 1 ;// 评价差

    private Long id;
    //跟进时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date traceTime;
    //跟进内容
    private String traceDetails;
    //跟进方式
    private SystemDictionaryItem traceType;
    //跟进结果
    private Integer traceResult;
    //客户
    private Customer customer;
    //录入人
    private Employee inputUser;

    public String getTraceResultName() {
        switch (traceResult) {
            case TRACERESULT_COMMON:
                return "优";
            case TRACERESULT_NORMAL:
                return "中";
            case TRACERESULT_FAIL:
                return "差";
            default:
                return "未评价";
        }
    }

    public String getJson(){
        HashMap map = new HashMap();
        map.put("id",id);
        map.put("traceTime",traceTime);
        map.put("traceDetails",traceDetails);
        map.put("traceResult",traceResult);
        if(traceType!=null){
            map.put("traceTypeId",traceType.getId());
        }
        if(customer!=null){
            map.put("customerId",customer.getId());
        }
        if(inputUser!=null){
            map.put("inputUserId",inputUser.getId());
        }
        return JSON.toJSONString(map);
    }

}